package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.console.facade.domain.SysMasterSlaveEdit;
import com.econ.powercloud.ems.aop.UserOperatePower;
import com.econ.powercloud.ems.rpc.IFeignPowerNodeConsoleClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : zjf
 * @Description : 主备切换controller
 * @Date : 2022/11/21 17:46
 * @Modified by : zjf
 */
@Api(tags = "主备切换")
@RestController
@RequestMapping(value = "/api/v2/masterSlave")
public class SysMasterSlaveController extends ApiBaseController{

    @Autowired
    private IFeignPowerNodeConsoleClient iFeignPowerNodeConsoleClient;

    @ApiOperation(value = "获取主备切换数据")
    @GetMapping
    public MsgResult getInfo(){
        return successHandler(iFeignPowerNodeConsoleClient.getInfo());
    }

    @ApiOperation(value = "修改访问方式")
    @PutMapping
    @UserOperatePower
    public MsgResult modifyAccessMethod(@RequestBody @Validated SysMasterSlaveEdit edit){
        iFeignPowerNodeConsoleClient.modifyAccessMethod(edit);
        return successHandler("切换成功!");
    }
}
